#ifndef _CANVAS_H_
#define _CANVAS_H_

#include <wx/wx.h>

// Canvas - 2D Zeichenfl�che in der wxWindows API.
// Einzige Methode zum Zeichnen: drawPixel(x,y,r,g,b)
class Canvas: public wxWindow {
  public:
    Canvas(wxWindow *parent, wxWindowID id);

  protected:
    int getWidth() const;
    int getHeight() const;
    void clear();
    void drawPixel(int x, int y, unsigned char r, unsigned char g,
      	unsigned char b);

    virtual void initCallback() { }
    virtual void resizeCallback() { }

    virtual void drawCallback() { }
    virtual void buttonPressCallback(int x, int y, int button) { }
    virtual void buttonReleaseCallback(int x, int y, int button) { }
    virtual void motionCallback(int x, int y, int dx, int dy, int button) { }

  private:
    wxImage _frameBuffer;
    int _oldMouseX, _oldMouseY;

    void onSize(wxSizeEvent &event);
    void onEraseBackground(wxEraseEvent &event);
    void onPaint(wxPaintEvent &event);
    void onMouseEvents(wxMouseEvent &event);

    DECLARE_EVENT_TABLE()
};

#endif // _CANVAS_H_
